using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace SpaceInvaders
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class Sprite : Microsoft.Xna.Framework.DrawableGameComponent
    {
        public int width, height;
        public Vector2 position;
        public Texture2D texture;
        public Texture2D textureTwo;
        public Vector2 velocity;
        public Color color;

        public Sprite(Game game, int width, int height, String location)
            : base(game)
        {
           this. width = width;
           this.height = height;
           this.texture = Game.Content.Load<Texture2D>(location);
            color = Color.White;

        }

        public Sprite(Game game, int width, int height, String location, String locationTwo)
            : base(game)
        {
            this.width = width;
            this.height = height;
            this.texture = Game.Content.Load<Texture2D>(location);
            textureTwo = Game.Content.Load<Texture2D>(locationTwo);
            color = Color.White;

        }



        public bool Collides(Sprite sprite)
        {
            Rectangle passedIn = new Rectangle((int)sprite.position.X, (int)sprite.position.Y, sprite.width, sprite.height);

            Rectangle current = new Rectangle((int)this.position.X, (int)this.position.Y, this.width,this.height);

            return passedIn.Intersects(current);
            
        }
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here

            base.Initialize();
        }

        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = Game.Services.GetService(typeof (SpriteBatch)) as SpriteBatch;

            spriteBatch.Begin();
            spriteBatch.Draw(texture,new Rectangle((int)position.X, (int) position.Y, width, height), color);
            spriteBatch.End();
            base.Draw(gameTime);
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here

            base.Update(gameTime);
        }
    }
}
